const querySql = require("../db");
const queryCount = async (table, condition) => {
  let sql = "";
  // console.log(condition);
  if (condition) {
    sql = `select count(*) as count from ${table} where ${condition} `;
  } else {
    sql = `select count(*) as count from ${table}`;
  }
  const [{ count }] = await querySql(sql);
  return count;
};
module.exports = queryCount;
